package com.ruoyi.web.controller.production.graftinglabel;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.graftinglabel.GraftinglabelType;
import com.ruoyi.production.service.graftinglabel.IGraftinglabelTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 嫁接签类型Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/graftinglabelType")
public class GraftinglabelTypeController extends BaseController
{
    @Autowired
    private IGraftinglabelTypeService graftinglabelTypeService;

    /**
     * 查询嫁接签类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:list')")
    @GetMapping("/list")
    public TableDataInfo list(GraftinglabelType graftinglabelType)
    {
        startPage();
        List<GraftinglabelType> list = graftinglabelTypeService.selectGraftinglabelTypeList(graftinglabelType);
        return getDataTable(list);
    }

    /**
     * 导出嫁接签类型列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:export')")
    @Log(title = "嫁接签类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GraftinglabelType graftinglabelType)
    {
        List<GraftinglabelType> list = graftinglabelTypeService.selectGraftinglabelTypeList(graftinglabelType);
        ExcelUtil<GraftinglabelType> util = new ExcelUtil<GraftinglabelType>(GraftinglabelType.class);
        return util.exportExcel(list, "嫁接签类型数据");
    }

    /**
     * 获取嫁接签类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:query')")
    @GetMapping(value = "/{graftinglabelTypeId}")
    public AjaxResult getInfo(@PathVariable("graftinglabelTypeId") Long graftinglabelTypeId)
    {
        return AjaxResult.success(graftinglabelTypeService.selectGraftinglabelTypeById(graftinglabelTypeId));
    }

    /**
     * 新增嫁接签类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:add')")
    @Log(title = "嫁接签类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GraftinglabelType graftinglabelType)
    {
        return toAjax(graftinglabelTypeService.insertGraftinglabelType(graftinglabelType));
    }

    /**
     * 修改嫁接签类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:edit')")
    @Log(title = "嫁接签类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GraftinglabelType graftinglabelType)
    {
        return toAjax(graftinglabelTypeService.updateGraftinglabelType(graftinglabelType));
    }

    /**
     * 删除嫁接签类型
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelType:remove')")
    @Log(title = "嫁接签类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{graftinglabelTypeIds}")
    public AjaxResult remove(@PathVariable Long[] graftinglabelTypeIds)
    {
        return toAjax(graftinglabelTypeService.deleteGraftinglabelTypeByIds(graftinglabelTypeIds));
    }
}
